package com.skypan.app2;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private LineChart mLine1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        mLine1 = (LineChart) findViewById(R.id.line1);
        setContentView(R.layout.activity_main);
        mLine1 = (LineChart) findViewById(R.id.line1);

//4.0创建y值数据
        List<Entry> yVals = new ArrayList<>();
        yVals.add(new Entry(0,35));
        yVals.add(new Entry(1,11));
        yVals.add(new Entry(2,52));
        yVals.add(new Entry(3,45));
        yVals.add(new Entry(4,69));
        yVals.add(new Entry(5,62));
        yVals.add(new Entry(6,14));
        List<Entry> yVals2 = new ArrayList<>();
        yVals2.add(new Entry(0,12));
        yVals2.add(new Entry(1,34));
        yVals2.add(new Entry(2,44));
        yVals2.add(new Entry(3,48));
        yVals2.add(new Entry(4,66));
        yVals2.add(new Entry(5,70));
        yVals2.add(new Entry(6,50));

        LineDataSet lineDataSet = new LineDataSet(yVals, "折线图1");
        LineDataSet lineDataSet2 = new LineDataSet(yVals2, "折线图2");
        lineDataSet.setCircleColor(Color.RED);
        lineDataSet2.setCircleColor(Color.BLUE);
        lineDataSet2.setColor(Color.YELLOW);
        lineDataSet.setColor(Color.GREEN);

        LineData lineData = new LineData();
        lineData.addDataSet(lineDataSet);



        lineData.addDataSet(lineDataSet2);



        mLine1.setData(lineData);




    }
}
